package com.example.demo.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.example.demo.config.db.interceptor.Encrypt;
import com.example.demo.config.db.interceptor.Encrypted;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
/**
 * CREATE TABLE `user` (
 *   `id` varchar(36) NOT NULL COMMENT 'ID',
 *   `username` varchar(20) NOT NULL COMMENT '姓名',
 *   `password` varchar(20) NOT NULL COMMENT '年龄',
 *   PRIMARY KEY (`id`)
 * ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 */

/**
 * 
 * @TableName user
 */
@TableName(value ="user")
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class User implements Encrypted, Serializable {

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public String[] getEncryptFields() {
        return new String[]{"username", "password"};
    }

    /**
     * ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private String id;

    /**
     * 姓名
     */
    @TableField(value = "username")
    @Encrypt
    private String username;

    /**
     * 年龄
     */
    @TableField(value = "password")
    @Encrypt
    private String password;

    @TableField(value = "deleted")
    private String deleted;
}